/**
 * Created with IntelliJ IDEA.
 * Description:二叉树的实现
 * User: 晓星航
 * Date: 2023-03-17
 * Time: 10:13
 */
class BTNode {
    public char val;
    public BTNode left;//左孩子的引用
    public BTNode right;//右孩子的引用
    public BTNode(char val) {
        this.val = val;
    }
}
public class BinaryTree {
    public BTNode root;//二叉树的根结点

    public BTNode creatTree (){
        BTNode A = new BTNode('A');
        BTNode B = new BTNode('B');
        BTNode C = new BTNode('C');
        BTNode D = new BTNode('D');
        BTNode E = new BTNode('E');
        BTNode F = new BTNode('F');
        BTNode G = new BTNode('G');
        BTNode H = new BTNode('H');
        A.left = B;
        A.right = C;
        B.left = D;
        B.right = E;
        E.right = H;
        C.left = F;
        C.right = G;
        return A;
    }
    void preOrder(BTNode root) {
        if (root == null) {
            return;
        }
        System.out.print(root.val + " ");
        preOrder(root.left);
        preOrder(root.right);
    }

    void minOrder(BTNode root) {
        if (root == null) {
            return;
        }
        System.out.println(root.left.val);
        minOrder(root);
        minOrder(root.right);
    }

    void lastOrder(BTNode root) {
        if (root == null) {
            return;
        }
        System.out.println(root.left.val);
        lastOrder(root.right);
        lastOrder(root);
    }
}
